import React, { useState } from 'react';
import '../public/static/css/index.css'; // 导入样式文件

const AddBookForm = ({ addBook }) => {
  const [title, setTitle] = useState('');

  const handleSubmit = (e) => {
    e.preventDefault();
    addBook(title);
    setTitle('');
  };

  return (
    <div className="form-group">
      <label className="label" htmlFor="title">书名:</label>
      <input
        className="input"
        type="text"
        id="title"
        value={title}
        onChange={(e) => setTitle(e.target.value)}
      />
      <button className="button" onClick={handleSubmit}>添加图书</button>
    </div>
  );
};

export default AddBookForm;
